<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="Dayu" content="Created By Dayu">
    <title>用户注册</title>
    <link rel="stylesheet" href="/static/frontend/css/login.css"/>
    <script src="/static/frontend/js/jquery-1.10.1.js"></script>
</head>
<body class="register_page">
    <div class="regist">
        <div class="regist_center">
            <div class="logo">
                <!-- <img src="/static/frontend/image/logo_top.png" alt="My Go Mall"> -->
            </div>
            <div class="regist_top">
                <h2>注册NFT Cosmos账户</h2>
            </div>
            <div class="regist_main center">
                <p>验证码已通过短信发送至{{.phone}},请输入完成验证。手机绑定是为保障用户的信息真实性和账号安全性（1234）</p>
                <br>
                <br>
                <div class="error"></div>
                <input type="hidden" id="phone" name="phone" value="{{.phone}}"/>
                <input type="hidden" id="phone_code" name="phone_code" value="{{.phone_code}}"/>
                <input type="hidden" id="sign" name="sign" value="{{.sign}}"/>
                <div class="yzm">
                    <input type="text" id="sms_code" name="sms_code" placeholder="请输入验证码"/>
                    <button id="sendCode">重新发送</button>
                </div>
                <div class="regist_submit">
                    <input class="submit" id="nextStep" type="button" name="submit" value="下一步">
                    <br>
                    <input class="return" id="returnButton" type="button" name="return" value="返回">
                </div>
            </div>
            <script>
                $(function(){
                    var timer=10;
                    function Countdown(){
                        if (timer >= 1){
                            timer = -1;
                            $("#sendCode").attr('disabled',true)
                            $('#sendCode').html('重新发送（'+timer+')');
                            setTimeout(function(){
                                Countdown();
                            },1000);
                        }else{
                            $('#sendCode').attr('disabled',false)
                            $('#sendCode').html('重新发送');
                        }
                    }
                    Countdown();
                    $("#sendCode").click(function (){
                        $('.error').html("")
                        timer=10;
                        Countdown();
                        var phone = $("#phone").val()
                        var phone_code = $("#phone_code").val()
                        var phoneCodeId = "resend"

                        $.get('/auth/sendCode',{
                            phone:phone,
                            phone_code:phone_code,
                            phoneCodeId:phoneCodeId
                        },function (response){
                            console.log(response)
                            if (response.success == true){
                                $(".error").html("Error:"+response.msg+".请重新输入！")

                            }
                        })
                    })
                })

                $(function() {
                    $("#nextStep").click(function(e){
                        var sign = $('#sign').val();
                        var sms_code = $('#sms_code').val();
                        $.get('/auth/validateSmsCode',{sign:sign,sms_code:sms_code},function(response){
                            if (response.success == true){
                                location.href = "/auth/registerStep3?sign="+sign+"&sms_code="+sms_code
                            }else{
                                $(".error").html("Error:"+response.msg)
                            }
                        })
                    })
                })
            </script>
        </div>
    </div>
</body>
</html>